<template>
  <div class="app-container ">
    <el-form ref="form" size="mini" :model="form" :rules="rules" label-width="180px">
      <el-tabs v-model="activeName">

        <el-row>
          <el-col :span="24">
            <el-form-item label="百度地图key">
              <el-input v-model="form.baiduak" auto-complete="off" clearable placeholder="请输入百度地图key" />
              <div class="help-block">免费的api接口每天有限制使用额，建议百度腾讯都申请</div>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="24">
            <el-form-item label="腾讯地图key">
              <el-input v-model="form.qqak" auto-complete="off" clearable placeholder="腾讯地图key" />
              <div class="help-block">免费的api接口每天有限制使用额，建议百度腾讯都申请</div>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="24">
            <el-form-item label="天地地图key">
              <el-input v-model="form.tdtk" auto-complete="off" clearable placeholder="腾讯地图key" />
              <div class="help-block" />
            </el-form-item>
          </el-col>
        </el-row>

      </el-tabs>
      <el-form-item>
        <el-button size="mini" type="primary" @click="submit">保存设置</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
import Tag from '@/components/common/Tag.vue'
export default {
  name: 'Sitesetuplbsapi',
  components: {
  },
  data() {
    return {
      form: {},
      select: {},
      loading: false,
      activeName: '基本信息',
      rules: {
      }
    }
  },
  mounted() {
    this.$api.post('/config/getField').then(res => {
      this.select = res.data
    })
    this.$api.post('/config/getInfo', {
      mo: 'lbsapi'
    }).then(res => {
      this.form = JSON.stringify(res.data) == '[]' ? {} : res.data
    })
  },
  methods: {
    submit() {
      this.$refs['form'].validate(valid => {
        if (valid) {
          this.loading = true
          this.$api.post('/config/update', this.form).then(res => {
            this.$message({ message: '操作成功', type: 'success' })
          }).catch(() => {
            this.loading = false
          })
        }
      })
    }
  }
}
</script>
